{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import plotly.offline as py\n",
    "import plotly.graph_objs as go\n",
    "import plotly.figure_factory as ff\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import yfinance as yf\n",
    "import pandas_datareader as pdr\n",
    "\n",
    "py.init_notebook_mode()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = [ i for i in range(-10,10) ]\n",
    "\n",
    "y = [ i*2 for i in range(-10,10) ]\n",
    "\n",
    "xaxis = go.layout.XAxis(title=\"X Axis\")\n",
    "yaxis = go.layout.YAxis(title=\"Y Axis\")\n",
    "\n",
    "fig = go.Figure(layout=go.Layout(title=\"Simple Line Plot\", xaxis=xaxis, yaxis=yaxis))\n",
    "fig.add_trace(go.Scatter(x=x, y=y))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "def sigmoid(x):\n",
    "    return 1 / (1 + np.exp((-1) * x))\n",
    "\n",
    "x = sorted(np.random.random(100) * 10 - 5)\n",
    "y = [ sigmoid(i) for i in x ]\n",
    "\n",
    "xaxis = go.layout.XAxis(title=\"X Axis\")\n",
    "yaxis = go.layout.YAxis(title=\"Y Axis\")\n",
    "\n",
    "fig=go.Figure(layout=go.Layout(title=\"Sigmoid Plot\",xaxis=xaxis, yaxis=yaxis))\n",
    "fig.add_trace(go.Scatter(x=x, y=y, marker=dict(color=\"red\")))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "l = []\n",
    "\n",
    "for _ in range(5):\n",
    "    l.append([ sorted(np.random.randint(low=0, high=10000, size=50)), sorted(np.random.randint(low=0, high=10000, size=50)) ])\n",
    "\n",
    "l = np.array(l)\n",
    "\n",
    "figure = go.Figure(layout=go.Layout(title=\"Simple Scatter Example\", xaxis=go.layout.XAxis(title=\"X\"), yaxis=go.layout.YAxis(title=\"Y\")))\n",
    "for i in range(len(l)):\n",
    "    figure.add_trace(go.Scatter(x=l[i][0],y=l[i][1], mode=\"markers\", name=f\" Distribution {i+1} \"))\n",
    "figure.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "dist = np.random.normal(loc=0, scale=1, size=50000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "figure = go.Figure()\n",
    "figure.add_trace(go.Histogram(x=dist,))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "d=[{\"values\":np.random.normal(0,0.5,10000), \"information\": \" Normal Distribution with mean 0 and std= 0.5\"},\n",
    "  {\"values\":np.random.normal(0,1,10000), \"information\": \" Normal Distribution with mean 0 and std= 1\"},\n",
    "  {\"values\":np.random.normal(0,1.5,10000), \"information\": \" Normal Distribution with mean 0 and std= 1.5\"},\n",
    "  {\"values\":np.random.normal(0,2,10000), \"information\": \" Normal Distribution with mean 0 and std= 2\"},\n",
    "  {\"values\":np.random.normal(0,5,10000), \"information\": \" Normal Distribution with mean 0 and std= 5\"}]\n",
    "\n",
    "ff.create_distplot([ele[\"values\"] for ele in d], group_labels=[ele[\"information\"] for ele in d], show_hist=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = np.random.randint(low=5, high=100, size=15)\n",
    "y = np.random.randint(low=5, high=100 ,size=15)\n",
    "z = np.random.randint(low=5, high=100, size=15)\n",
    "\n",
    "fig = go.Figure()\n",
    "fig.add_trace(go.Scatter3d(x=x, y=y, z=z, mode=\"markers\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_iris = pd.read_csv(\"iris.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = go.Figure()\n",
    "species_types = df_iris.species.unique().tolist()\n",
    "\n",
    "for specie in species_types:\n",
    "    b = df_iris.species == specie\n",
    "    fig.add_trace(go.Scatter3d(x=df_iris[\"sepal_length\"][b], y=df_iris[\"sepal_width\"][b], z=df_iris[\"petal_width\"][b], name=specie, mode=\"markers\"))\n",
    "\n",
    "\n",
    "fig.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "yf.pdr_override()\n",
    "\n",
    "symbols = [\"AAPL\",\"MSFT\"]\n",
    "stocks = []\n",
    "for symbol in symbols:\n",
    "    stocks.append(pdr.get_data_yahoo(symbol, start=\"2020-01-01\", end=\"2020-05-31\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "fig = go.Figure()\n",
    "\n",
    "for stock,symbol in zip(stocks,symbols):\n",
    "    fig.add_trace(go.Scatter(x=stock.index, y=stock.Close, name=symbol))\n",
    "\n",
    "fig.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_aapl = pdr.get_data_yahoo(symbol, start=\"2020-01-01\", end=\"2020-05-31\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "ff.create_candlestick(dates=df_aapl.index, open=df_aapl.Open, high=df_aapl.High, low=df_aapl.Low, close=df_aapl.Close)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
